﻿Imports System.Data      'Importo lo necesario para trabajar con ODBC 
Imports System.Data.Odbc '
Imports System.Data.OleDb
Imports System.Data.SqlClient

Public Class Dato1

    Public cn As SqlConnection
    Public conectarme As New OleDbConnection
    Sub New()
        '    cn = New SqlConnection("UID=root" & _
        '";PWD=root" & _
        '";DATABASE=horarios" & _
        '";SERVER=localhost" & _
        '";DRIVER={MySQL ODBC 5.1 Driver};")

        conectarme.ConnectionString = "UID=root" & _
        ";PWD=root" & _
        ";DATABASE=horarios" & _
        ";SERVER=localhost" & _
        ";DRIVER={MySQL ODBC 5.1 Driver};"
        conectarme.Open()


    End Sub
    Function agregahorario(nodo As Entidades.Horarios) As Boolean

        'Try
        '    Dim cmd As OdbcCommand = New OdbcCommand("{call agregahorarios (?,?,?)}", cn)
        '    cmd.CommandType = CommandType.StoredProcedure
        '    cmd.Parameters.AddWithValue("@horai", nodo.phoraini)
        '    cmd.Parameters.AddWithValue("@horaf", nodo.phorafin)
        '    cmd.Parameters.AddWithValue("@h", nodo.phora)

        '    cn.Open()
        '    cmd.ExecuteNonQuery()


        'Catch o As OdbcException
        '    MsgBox(o.Message.ToString)
        '    Return False
        'Finally
        '    cn.Close()

        'End Try
        Return True

    End Function
    Function modificahorario(nodo As Entidades.Horarios) As Boolean
        Return True

    End Function
    Function eliminahorario(nodo As Entidades.Horarios) As Boolean
        Return True

    End Function
    Function consultahorarios() As DataSet

        Dim conn As SqlConnection = Nothing

        Dim ds As New DataSet

        Dim rdr As SqlDataReader = Nothing


        Try
            Dim cmd As SqlCommand = New SqlCommand("{call consultahorarios ()}", cn)
            cmd.CommandType = CommandType.StoredProcedure


            Dim dap As New SqlDataAdapter
            dap.SelectCommand = cmd
            dap.Fill(ds)


            Return ds


        Catch ex As Exception
            MsgBox(ex.ToString)
            Return ds

        End Try
    End Function
End Class
